package com.zatech.cgnci.project.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zatech.cgnci.project.base.utils.ConvertUtils;
import com.zatech.cgnci.project.dto.CgnciUserInfoQueryDTO;
import com.zatech.cgnci.project.entity.CgnciUserInfoDO;
import com.zatech.cgnci.project.service.CgnciUserInfoService;
import com.zatech.cgnci.project.vo.CgnciCompanyVO;
import com.zatech.cgnci.project.vo.CgnciUserInfoPageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 人员信息表 前端控制器
 * </p>
 *
 * @author Generator
 * @since 2025-03-12
 */
@RestController
@RequestMapping("/api/userInfo")
@Api(produces = "application/json", tags = "人员信息表api接口文档")
@RequiredArgsConstructor
public class CgnciUserInfoController {

    private final CgnciUserInfoService cgnciUserInfoService;

    @GetMapping("/listCompany")
    @ApiOperation(value = "获取企业信息")
    public List<CgnciCompanyVO> listCompany() {
        List<CgnciUserInfoDO> list = cgnciUserInfoService.list(new LambdaQueryWrapper<CgnciUserInfoDO>()
                .groupBy(CgnciUserInfoDO::getCompanyCode, CgnciUserInfoDO::getCompanyName));
        return ConvertUtils.convert(list, CgnciCompanyVO.class);
    }


    @PostMapping("/page")
    @ApiOperation(value = "分页人员信息查询")
    public IPage<CgnciUserInfoPageVO> pageUserInfo(@RequestBody CgnciUserInfoQueryDTO queryDTO) {
        return cgnciUserInfoService.pageUserInfo(queryDTO);
    }



}

